package migrations

import (
	"database/sql"

	"gitee.com/sweetsunnyflower/carpooling-server-go/app/models"
	"gitee.com/sweetsunnyflower/carpooling-server-go/pkg/migrate"

	"gorm.io/gorm"
)

// http://sql2struct.atotoa.com/
func init() {

	// 行程评价表
	type TripEvaluation struct {
		models.BaseModel

		UserId     uint64 `gorm:"column:user_id" db:"user_id" json:"user_id" form:"user_id"`                                      //用户ID
		TripId     uint64 `gorm:"column:trip_id;comment:行程id;" db:"trip_id" json:"trip_id" form:"trip_id"`                        //行程ID
		Evaluation uint8  `gorm:"column:evaluation;comment:1:满意 2不满意 3:还可以;" db:"evaluation" json:"evaluation" form:"evaluation"` //1:满意，2：不满意，3:还可以
		Anonymous  uint8  `gorm:"column:anonymous;comment:1匿名 2实名;" db:"anonymous" json:"anonymous" form:"anonymous"`             //是否匿名，1：匿名，2：实名
		Comments   string `gorm:"type:varchar(255);comment:评论内容;" db:"comments" json:"comments" form:"comments"`                  //评论内容

		models.CommonTimestampsField
	}

	up := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.AutoMigrate(&TripEvaluation{})
	}

	down := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.DropTable(&TripEvaluation{})
	}

	migrate.Add("2023_07_18_143810_add_trip_evaluations_table", up, down)
}
